package com.wjerp.tplus.server.common.utils;


import org.apache.commons.text.RandomStringGenerator;

import java.util.Random;
import java.util.UUID;

/**
 * @author lishuailei
 */
public class StaticMethods {
    public static Integer generateMerchantId() {
        Random number = new Random();
        Integer merchantId = number.nextInt((999999 - 100000) + 1) + 100000;
        return merchantId;
    }

    public static String generatePasswordResetEmailCode(){
        return generatePlatformUserId().toString();
    }

    public static Integer generatePlatformUserId() {
        Random number = new Random();
        Integer platformUserId = number.nextInt((999999 - 100000) + 1) + 100000;
        return platformUserId;
    }

    public static String generateUniqueToken(){
        return UUID.randomUUID().toString().replaceAll("-", "");
    }
    public static String generateImageId() { return UUID.randomUUID().toString().replaceAll("-", ""); }

    public static String getFileExtension(String fileName) {
        if(fileName.lastIndexOf(".") != -1 && fileName.lastIndexOf(".") != 0)
            return fileName.substring(fileName.lastIndexOf(".")+1);
        else return "";
    }

    public static String generateRandomCaptchaText() { return new RandomStringGenerator.Builder().withinRange('a', 'z').build().generate(4); }
    public static String generateCaptchaToken() { return UUID.randomUUID().toString().replaceAll("-", ""); }

}
